package com.geek.controller;

import com.geek.bean.BaseRespVo;
import com.geek.bean.data.ResponseSearchIndexData;
import com.geek.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wbw
 * @data 2024/06/17 15:03
 **/
@RestController
@RequestMapping("wx/search")
public class WxSearchController {
    @Autowired
    SearchService searchService;

    @GetMapping("index")
    public BaseRespVo index(){
        ResponseSearchIndexData data = searchService.index();
        return BaseRespVo.ok(data);
    }
    @GetMapping("helper")
    public BaseRespVo helper(String keyword){
        List<String> data = searchService.helperKeyword(keyword);
        return BaseRespVo.ok(data);
    }
    @PostMapping("clearhistory")
    public Map<String,Object> clearHistory(){
        Map<String,Object> map = new HashMap<>();
        searchService.clearHistory();
        map.put("errmsg","成功");
        map.put("errno",0);
        return map;
    }
}
